package com.ruoyi.web.controller.fenxi;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ROrgRiskException;
import com.ruoyi.system.service.IROrgRiskExceptionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 风险异常事件事件列Controller
 * 
 * @author ruoyi
 * @date 2022-09-25
 */
@Controller
@RequestMapping("/system/exception")
public class ROrgRiskExceptionController extends BaseController
{
    private String prefix = "system/exception";

    @Autowired
    private IROrgRiskExceptionService rOrgRiskExceptionService;

    @RequiresPermissions("system:exception:view")
    @GetMapping()
    public String exception()
    {
        return prefix + "/exception";
    }

    /**
     * 查询风险异常事件事件列列表
     */
    @RequiresPermissions("system:exception:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ROrgRiskException rOrgRiskException)
    {
        startPage();
        List<ROrgRiskException> list = rOrgRiskExceptionService.selectROrgRiskExceptionList(rOrgRiskException);
        return getDataTable(list);
    }

    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo glist(ROrgRiskException rOrgRiskException)
    {
        startPage();
        List<ROrgRiskException> list = rOrgRiskExceptionService.selectROrgRiskExceptionList(rOrgRiskException);
        return getDataTable(list);
    }
    /**
     * 导出风险异常事件事件列列表
     */
    @RequiresPermissions("system:exception:export")
    @Log(title = "风险异常事件事件列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ROrgRiskException rOrgRiskException)
    {
        List<ROrgRiskException> list = rOrgRiskExceptionService.selectROrgRiskExceptionList(rOrgRiskException);
        ExcelUtil<ROrgRiskException> util = new ExcelUtil<ROrgRiskException>(ROrgRiskException.class);
        return util.exportExcel(list, "风险异常事件事件列数据");
    }

    /**
     * 新增风险异常事件事件列
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存风险异常事件事件列
     */
    @RequiresPermissions("system:exception:add")
    @Log(title = "风险异常事件事件列", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ROrgRiskException rOrgRiskException)
    {
        return toAjax(rOrgRiskExceptionService.insertROrgRiskException(rOrgRiskException));
    }

    /**
     * 修改风险异常事件事件列
     */
    @RequiresPermissions("system:exception:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ROrgRiskException rOrgRiskException = rOrgRiskExceptionService.selectROrgRiskExceptionById(id);
        mmap.put("rOrgRiskException", rOrgRiskException);
        return prefix + "/edit";
    }

    /**
     * 修改保存风险异常事件事件列
     */
    @RequiresPermissions("system:exception:edit")
    @Log(title = "风险异常事件事件列", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ROrgRiskException rOrgRiskException)
    {
        return toAjax(rOrgRiskExceptionService.updateROrgRiskException(rOrgRiskException));
    }

    /**
     * 删除风险异常事件事件列
     */
    @RequiresPermissions("system:exception:remove")
    @Log(title = "风险异常事件事件列", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(rOrgRiskExceptionService.deleteROrgRiskExceptionByIds(ids));
    }
}
